----------------------------------Spell Variables--------------------------------------
SPELL.m_iSpellID = 51314 -- Whatever value you want as long as it doesn't override any other spells' IDs.
SPELL.m_iRange = 512
SPELL.m_sName = "Bull Rush"
SPELL.m_sToolTip = [[Dash directly to your 
					selected target, dealing
					20 damage.]]
SPELL.m_sIcon = "devin/blackbetty/spells/warrior/rush.png"
SPELL.m_iCoolDown = 16
SPELL.m_iManaCost = 0
SPELL.m_bRequiresTarget = true
SPELL.m_iSpellType = SPELLTYPE_MOBILITY
SPELL.m_bRecastWhileCasting = false

---------------------------------------------------------------------------------------

function SPELL:Cast( pl, target )
	
	pl:EmitSound("devin/blackbetty/weapons/BullRush.wav", 160, 100)
	local subtractedvectors = (pl:GetPos()) - target:GetPos()
	local subtractedvectorsnorm = (pl:GetPos()) - target:GetPos()
	subtractedvectorsnorm:Normalize()
	pl:DoAnimationEvent(ACT_HL2MP_RUN_PROTECTED)
	pl:SetPos(pl:GetPos() + Vector(0, 0, 32))
	pl:SetAngles((target:GetPos() - pl:GetPos()):Angle())
	pl:SetVelocity(-(subtractedvectorsnorm*(2*subtractedvectors:Length()+378)))
	UpdatePlayerResource(pl, 25)
	target.Speed = true	
		target.SpeedMod = -1
		target.SpeedModDuration = 0.7
		target.SpeedType = "Charge"
	target:SetVelocity(target:GetVelocity()*-1) 
	timer.Simple(0.3, function()
		
		ParticleEffect( "player_blood", target:GetPos() + Vector(0, 0, 46) + (target:GetAngles():Forward()*6), Angle(0,0,0), pl )
		target:EmitSound("devin/blackbetty/weapons/Warrior_ShockWave_Area.wav", 160, 100)
		self:Effect(pl, target, 1)
		self:ApplySpellMods(self, pl, target)
		target.Speed = true 
		target.SpeedMod = 0.5
		target.SpeedModDuration = 5
		target.SpeedType = "Charge"
		pl:SetVelocity(pl:GetVelocity()*-1)
		pl:SetNWBool("Casting", false) 
		pl:SetNWBool("Casted", false)
	end)

end

function SPELL:Effect(pl, target, damagemod)
	if( damagemod == nil )then
		damagemod = 1
	end
	target:EmitSound("devin/blackbetty/weapons/2hMaceHitPlateCrit.wav", 160, 100)
	ParticleEffect( "pummel_hit", target:GetPos() + Vector(0, 0, 45), Angle(0,0,0), target )
	ParticleEffect( "player_blood", target:GetPos() + Vector(0, 0, 46) + (target:GetAngles():Forward()*6), Angle(0,0,0), pl )
	self:DealDamage(20*damagemod, 20*damagemod, pl, target, DMG_GENERIC)
end



